package com.chinadrtv.batch.admin.jobs.ozing.paid;

import com.chinadrtv.user.service.ozing.OzingCardService;
import com.chinadrtv.user.model.OzingCard;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 *
 * @author Jack Chen
 * Date: 12-12-18
 *
 */
public class PaidCardItemWriter implements ItemWriter<OzingCard> {
    private static Log log = LogFactory.getLog(PaidCardItemWriter.class);


    @Autowired
    private OzingCardService ozingCardService;

    public void write(List<? extends OzingCard> items) throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("*****start to run paid card job: writer******");
        }
        for (OzingCard item : items) {
            ozingCardService.save(item);
        }
    }
}
